package org.jeecg.modules.maps.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.maps.entity.BimMaps;
import org.jeecg.modules.maps.model.param.BuildFloorQuery;
import org.jeecg.modules.maps.service.IBimMapsService;
import org.jeecg.modules.project.entity.BuildResultType;
import org.jeecg.modules.project.model.params.BimProjectFloorParam;
import org.jeecg.modules.project.service.IBimProjectBuildService;
import org.jeecg.modules.project.service.IProjectInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Description: bim_geo_api
 * @Author: jeecg-boot
 * @Date: 2022-12-05
 * @Version: V1.0
 */
@Api(tags = "贴图管理")
@RestController
@RequestMapping("/bim/maps")
@Slf4j
public class BimMapsController extends JeecgController<BimMaps, IBimMapsService> {

    @Autowired
    private IBimProjectBuildService bimProjectBuildService;

    @Autowired
    private IProjectInfoService projectInfoService;
    /**
     * 贴图编辑提交
     *
     * @param buildParamList
     * @return bimProjectBuildResult
     */
    @ApiOperation(value = "贴图编辑提交", notes = "贴图编辑提交")
    @PostMapping(value = "/edit")
    public Result<?> edit(@RequestBody @Valid List<BimProjectFloorParam>  buildParamList) {
        return Result.OK(bimProjectBuildService.editMap(buildParamList));
    }

    /**
     * 贴图编辑根据工程管理编码查询楼栋楼层贴图信息
     *
     * @param projectInfoId
     * @return bimProjectBuildResult
     */
    @ApiOperation(value = "贴图编辑根据工程管理编码查询楼栋楼层贴图信息", notes = "贴图编辑根据工程管理编码查询楼栋楼层贴图信息")
    @GetMapping(value = "/query")
    public Result<?> query(@RequestParam(name = "projectInfoId") Integer projectInfoId,
                           @RequestParam(name = "buildId",required = false) Integer buildId,
                           @RequestParam(name = "floorId",required = false) Integer floorId) {
        BuildFloorQuery query = new BuildFloorQuery();
        query.setProjectInfoId(projectInfoId);
        query.setBuildId(buildId);
        query.setFloorId(floorId);
        return Result.OK(projectInfoService.getProjBuildInfos(query, BuildResultType.MAP));
    }
}
